<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Example: Using the Drag Shim</title>
    <link rel="stylesheet" href="http://yui.yahooapis.com/3.4.0pr3/build/cssgrids/grids-min.css">
    <link rel="stylesheet" href="../assets/css/main.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <script src="../../build/yui/yui-min.js"></script>
</head>
<body>

<div id="doc">
    <h1>Example: Using the Drag Shim</h1>

    
        <a href="#toc" class="jump">Jump to Table of Contents</a>
    

    <div class="yui3-g">
        <div id="main" class="yui3-u">
            <div class="content"><div class="intro">
<p>This example shows the use of the drag shim when dragging nodes over other troublesome nodes.</p>
</div>

<div class="example">
    <style>
    #demo {
        height: 100px;
        width: 100px;
        border: 1px solid black;
        cursor: move;
        float: right;
    }
    #ifrm {
        width: 400px;
        height: 300px;
    }
</style>

<p>Try dragging the proxy element over the iframe below, in most browsers this will not happen. Now click the <code>Shim off</code> button and drag again. Now you can drag over the iframe.</p>

<p>You can see the shim by clicking the <code>Debug Off</code> button.</p>

<p><button id="shim" value="off">Shim Off</button> <button id="debugShim" value="off" disabled>Debug Off</button></p>

<div id="demo">Drag Me</div>

<iframe id="ifrm" src="../assets/dd/blank.htm"></iframe>

<script>
YUI().use('dd-ddm', 'dd-drag', 'dd-proxy', function(Y) {
        //Toggling the buttons
        Y.one('#shim').on('click', function(e) {
            var value = e.target.get('value');
            if (value == 'off' || value == 'Shim Off') {
                dd.set('useShim', true);
                e.target.set('value', 'on');
                e.target.set('innerHTML', 'Shim On');
                Y.one('#debugShim').set('disabled', false);
            } else {
                dd.set('useShim', false);
                e.target.set('value', 'off');
                e.target.set('innerHTML', 'Shim Off');
                Y.one('#debugShim').set('disabled', true);
            }
        });
        
        Y.one('#debugShim').on('click', function(e) {
            var value = e.target.get('value');
            if (value == 'off' || value == 'Debug Off') {
                Y.DD.DDM._debugShim = true;
                e.target.set('value', 'on');
                e.target.set('innerHTML', 'Debug On');
            } else {
                Y.DD.DDM._debugShim = false;
                e.target.set('value', 'off');
                e.target.set('innerHTML', 'Debug Off');
            }
        });
        
        var dd = new Y.DD.Drag({
            //Selector of the node to make draggable
            node: '#demo',
            useShim: false
        }).plug(Y.Plugin.DDProxy, {
            offsetNode: false,
            resizeFrame: false
        });
        dd.on('drag:start', function() {
            this.get('dragNode').setStyles({
                height: '20px',
                width: '100px',
                backgroundColor: 'blue',
                color: '#fff'
            });
            this.get('dragNode').set('innerHTML', 'Custom Proxy');
            this.deltaXY = [this.deltaXY[0] - 20, this.deltaXY[1] - 20];
        });
});


</script>

</div>

<h3 id="using-the-shim">Using the shim</h3>
<p>Full source code for this example.</p>

<pre class="code prettyprint">YUI().use(&#x27;dd-ddm&#x27;, &#x27;dd-drag&#x27;, &#x27;dd-proxy&#x27;, function(Y) {
        &#x2F;&#x2F;Toggling the buttons
        Y.one(&#x27;#shim&#x27;).on(&#x27;click&#x27;, function(e) {
            var value = e.target.get(&#x27;value&#x27;);
            if (value == &#x27;off&#x27; || value == &#x27;Shim Off&#x27;) {
                dd.set(&#x27;useShim&#x27;, true);
                e.target.set(&#x27;value&#x27;, &#x27;on&#x27;);
                e.target.set(&#x27;innerHTML&#x27;, &#x27;Shim On&#x27;);
                Y.one(&#x27;#debugShim&#x27;).set(&#x27;disabled&#x27;, false);
            } else {
                dd.set(&#x27;useShim&#x27;, false);
                e.target.set(&#x27;value&#x27;, &#x27;off&#x27;);
                e.target.set(&#x27;innerHTML&#x27;, &#x27;Shim Off&#x27;);
                Y.one(&#x27;#debugShim&#x27;).set(&#x27;disabled&#x27;, true);
            }
        });
        
        Y.one(&#x27;#debugShim&#x27;).on(&#x27;click&#x27;, function(e) {
            var value = e.target.get(&#x27;value&#x27;);
            if (value == &#x27;off&#x27; || value == &#x27;Debug Off&#x27;) {
                Y.DD.DDM._debugShim = true;
                e.target.set(&#x27;value&#x27;, &#x27;on&#x27;);
                e.target.set(&#x27;innerHTML&#x27;, &#x27;Debug On&#x27;);
            } else {
                Y.DD.DDM._debugShim = false;
                e.target.set(&#x27;value&#x27;, &#x27;off&#x27;);
                e.target.set(&#x27;innerHTML&#x27;, &#x27;Debug Off&#x27;);
            }
        });
        
        var dd = new Y.DD.Drag({
            &#x2F;&#x2F;Selector of the node to make draggable
            node: &#x27;#demo&#x27;,
            useShim: false
        }).plug(Y.Plugin.DDProxy, {
            offsetNode: false,
            resizeFrame: false
        });
        dd.on(&#x27;drag:start&#x27;, function() {
            this.get(&#x27;dragNode&#x27;).setStyles({
                height: &#x27;20px&#x27;,
                width: &#x27;100px&#x27;,
                backgroundColor: &#x27;blue&#x27;,
                color: &#x27;#fff&#x27;
            });
            this.get(&#x27;dragNode&#x27;).set(&#x27;innerHTML&#x27;, &#x27;Custom Proxy&#x27;);
            this.deltaXY = [this.deltaXY[0] - 20, this.deltaXY[1] - 20];
        });
});</pre>

</div>
        </div>

        <div id="sidebar" class="yui3-u">
            
                <div id="toc" class="sidebox">
                    <div class="hd">
                        <h2 class="no-toc">Table of Contents</h2>
                    </div>

                    <div class="bd">
                        <ul class="toc">
<li>
<a href="#using-the-shim">Using the shim</a>
</li>
</ul>
                    </div>
                </div>
            

            
                <div class="sidebox">
                    <div class="hd">
                        <h2 class="no-toc">Examples</h2>
                    </div>

                    <div class="bd">
                        <ul class="examples">
                            
                                
                                    <li data-description="A simple drag interaction that doesn&#x27;t require a drop interaction.">
                                        <a href="simple-drag.html">Simple Drag</a>
                                    </li>
                                
                            
                                
                                    <li data-description="How to apply the Drag Plugin to a node.">
                                        <a href="drag-plugin.html">Drag - Node plugin</a>
                                    </li>
                                
                            
                                
                                    <li data-description="A simple proxy drag interaction that doesn&#x27;t require a drop interaction.">
                                        <a href="proxy-drag.html">Drag - Proxy</a>
                                    </li>
                                
                            
                                
                                    <li data-description="How to constrain a draggable Node to another Node&#x27;s region.">
                                        <a href="constrained-drag.html">Drag - Constrained to a Region</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Using interaction groups, this example demonstrates how to tie into the Drag &amp; Drop Utility&#x27;s interesting moments to provide visual affordances for the current drag operation.">
                                        <a href="groups-drag.html">Drag - Interaction Groups</a>
                                    </li>
                                
                            
                                
                                    <li data-description="The use of the drag shim when dragging nodes over other troublesome nodes.">
                                        <a href="shim-drag.html">Using the Drag Shim</a>
                                    </li>
                                
                            
                                
                                    <li data-description="How to use the Drop Target events to code your application.">
                                        <a href="drop-code.html">Using Drop Based Coding</a>
                                    </li>
                                
                            
                                
                                    <li data-description="How you can use the DD Scroll plugin to scroll the browser window as you drag.">
                                        <a href="winscroll.html">Window Scrolling</a>
                                    </li>
                                
                            
                                
                                    <li data-description="How to use DD.Delegate to create a scalable solution which supports multiple draggable items.">
                                        <a href="delegate.html">Drag Delegation</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Using DD.Delegate to support dragging multiple items and dropping them onto a Drop Target.">
                                        <a href="delegate-drop.html">Drag Delegation with a Drop Target</a>
                                    </li>
                                
                            
                                
                                    <li data-description="How to use Drag plugins with a DD Delegate based solution.">
                                        <a href="delegate-plugins.html">Using Drag Plugins with Delegate</a>
                                    </li>
                                
                            
                                
                                    <li data-description="This example shows how to make a sortable list using Custom Event Bubbling.">
                                        <a href="list-drag.html">List Reorder w/Bubbling</a>
                                    </li>
                                
                            
                                
                                    <li data-description="This example shows how to make a sortable list using Custom Event Bubbling and Node Scrolling.">
                                        <a href="scroll-list.html">List Reorder w/Scrolling</a>
                                    </li>
                                
                            
                                
                                    <li data-description="How to make an animated node a Drop target.">
                                        <a href="anim-drop.html">Animated Drop Targets</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Example Photo Browser application.">
                                        <a href="photo-browser.html">Photo Browser</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Portal style example using Drag &amp; Drop Event Bubbling and Animation.">
                                        <a href="portal-drag.html">Portal Style Example</a>
                                    </li>
                                
                            
                                
                            
                                
                            
                        </ul>
                    </div>
                </div>
            

            
                <div class="sidebox">
                    <div class="hd">
                        <h2 class="no-toc">Examples That Use This Component</h2>
                    </div>

                    <div class="bd">
                        <ul class="examples">
                            
                                
                            
                                
                            
                                
                            
                                
                            
                                
                            
                                
                            
                                
                            
                                
                            
                                
                            
                                
                            
                                
                            
                                
                            
                                
                            
                                
                            
                                
                            
                                
                            
                                
                                    <li data-description="Working with multiple YUI instances.">
                                        <a href="../yui/yui-multi.html">Multiple Instances</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Use StyleSheet to adjust the CSS rules applying a page theme from user input">
                                        <a href="../stylesheet/stylesheet-theme.html">Adjusting a Page Theme on the Fly</a>
                                    </li>
                                
                            
                        </ul>
                    </div>
                </div>
            
        </div>
    </div>
</div>

<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>

</body>
</html>
